package com.autonavi.yunda.yunji.core.enums;

import com.autonavi.yunda.yunji.core.vo.node.*;
import lombok.Getter;

import java.util.Set;

/**
 * @author cizhong.wcs
 * @date 2022/5/24 14:42
 */
public enum NodeType {
    nope("空节点", NopeNode.class),
    start("start节点", StartNode.class),
    end("end节点", EndNode.class),
    sql("sql节点", SqlNode.class),

    yundaSQLData("sql类型数据零部件节点", YundaSQLDataNode.class),
    http("http节点", HttpNode.class),
    yundaTemplateSQLData("sql模板类型数据零部件节点", YundaTemplateSQLDataNode.class),
    yundaAPI("api零部件节点", YundaAPINode.class),
    transform("transform节点", TransformNode.class),
    groovy("自定义脚本节点", GroovyFunctionNode.class),
    javascript("自定义脚本节点", JsFunctionNode.class),
    redis("redis节点", RedisNode.class),
    edge("边节点", EdgeNode.class);

    NodeType(String desc, Class<? extends BaseNode> nodeClass) {
        this.desc = desc;
        this.nodeClass = nodeClass;
    }

    public static final Set<NodeType> SPECIAL_NODES = Set.of(nope, start, end);

    /**
     * nodeClass must implement BaseYundaComponentNode
     */
    public static final Set<NodeType> YUNDA_COMPONENT_NODES = Set.of(yundaAPI, yundaSQLData, yundaTemplateSQLData);

    public boolean isSpecial() {
        return SPECIAL_NODES.contains(this);
    }

    public boolean isYundaComponent() {
        return YUNDA_COMPONENT_NODES.contains(this);
    }

    @Getter
    private final String desc;
    @Getter
    private final Class<? extends BaseNode> nodeClass;
}
